﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UserService.IRepository;

namespace UserService.Repository
{
    public class ClientManager<TClient> : IDisposable where TClient : class
    {
        protected internal IClientStore<TClient> Store { get; set; }

        public ClientManager(IClientStore<TClient> store)
        {
            if (store == null)
            {
                throw new ArgumentNullException("store");
            }
            Store = store;
        }

        public virtual TClient FindByIdToClient(string clientId)
        {
            return Store.FindByIdRow(clientId);
        }

        public virtual bool AddClient(TClient obj)
        {

            return Store.CreateRow(obj);
        }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                Store.Dispose();
            }
        }
    }
}
